package com.zjdiepu.www.biz.zpp;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Optional;

import javax.annotation.Resource;

import net.sf.json.JSONObject;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.diepu.www.client.hzicbc.proxy.enums.BankCreditResultType;
import com.diepu.www.client.hzicbc.proxy.enums.RelationType;
import com.diepu.www.client.proxy.hzicbc.request.CreditResultInfo;
import com.diepu.www.client.proxy.hzicbc.request.CreditResultRequest;
import com.diepu.www.client.proxy.hzicbc.request.CreditResultRequest.CreditApply;
import com.diepu.www.client.proxy.hzicbc.request.ObtainFileList;
import com.diepu.www.client.proxy.hzicbc.request.ObtainFileListRequest;
import com.diepu.www.client.proxy.partner.request.own.DiepuZxQuerySuccessBusiIdUpRequest;
import com.zjdiepu.www.base.core.AbstractSysUser;
import com.zjdiepu.www.base.core.BaseException;
import com.zjdiepu.www.base.enums.status.AddedStatus1;
import com.zjdiepu.www.base.enums.status.ArchiveStatus;
import com.zjdiepu.www.base.enums.status.BusiStatus;
import com.zjdiepu.www.base.enums.status.CreditQueryStatus;
import com.zjdiepu.www.base.enums.status.DpStatus;
import com.zjdiepu.www.base.enums.status.LessInformationStatus;
import com.zjdiepu.www.base.enums.status.PhoneStatus;
import com.zjdiepu.www.base.enums.status.QueryCreditApplyStatus;
import com.zjdiepu.www.base.enums.status.TongrongStatus;
import com.zjdiepu.www.base.enums.type.CodeType;
import com.zjdiepu.www.base.enums.type.CreditPeopleType;
import com.zjdiepu.www.base.enums.type.CreditResult;
import com.zjdiepu.www.base.enums.type.ModeIDType;
import com.zjdiepu.www.base.enums.type.NewsType;
import com.zjdiepu.www.base.enums.type.ResultFlagType;
import com.zjdiepu.www.base.enums.type.TypeData;
import com.zjdiepu.www.common.util.DateUtil;
import com.zjdiepu.www.common.util.ZhppDateUtil;
import com.zjdiepu.www.dao.base.OtherAttachmentsMapper;
import com.zjdiepu.www.dao.icbc.OtherLoanLossProvisionMapper;
import com.zjdiepu.www.dao.icbc.YwOrdernoBankMapper;
import com.zjdiepu.www.dao.system.BaseCustomerMapper;
import com.zjdiepu.www.dao.system.BaseSalersmanMapper;
import com.zjdiepu.www.dao.yw.YwBusinessBuyerMapper;
import com.zjdiepu.www.dao.yw.YwBusinessMapper;
import com.zjdiepu.www.dao.zpp.PublicDao;
import com.zjdiepu.www.dao.zx.ZxCreditQueryMapper;
import com.zjdiepu.www.dao.zx.ZxQueryCreditApplyMapper;
import com.zjdiepu.www.dao.zx.ZxQueryCreditApplySubMapper;
import com.zjdiepu.www.ibiz.base.ISerialNumberService;
import com.zjdiepu.www.ibiz.third.IPhoneNumberAddrService;
import com.zjdiepu.www.ibiz.zpp.IcbcApiService;
import com.zjdiepu.www.ibiz.zpp.SystemService;
import com.zjdiepu.www.ibiz.zpp.YwShenQingZxService;
import com.zjdiepu.www.model.base.dto.OtherAttachments;
import com.zjdiepu.www.model.base.dto.SysUser;
import com.zjdiepu.www.model.base.ext.OtherAttachmentsExt;
import com.zjdiepu.www.model.icbc.dto.OtherLoanLossProvision;
import com.zjdiepu.www.model.icbc.dto.YwOrdernoBank;
import com.zjdiepu.www.model.system.dto.BaseCustomer;
import com.zjdiepu.www.model.system.dto.BaseSalersman;
import com.zjdiepu.www.model.yw.dto.YwBusiness;
import com.zjdiepu.www.model.yw.dto.YwBusinessBuyer;
import com.zjdiepu.www.model.zpp.pub.ext.DiepuCreditFeedbackExt;
import com.zjdiepu.www.model.zx.dto.ZxCreditQuery;
import com.zjdiepu.www.model.zx.dto.ZxQueryCreditApply;
import com.zjdiepu.www.model.zx.dto.ZxQueryCreditApplySub;
import com.zjdiepu.www.proxy.OwnDiepuService;
import com.zjdiepu.www.response.BooleanResponse;
import com.zjdiepu.www.security.server.core.Partners;
import com.zjdiepu.www.util.CommonUtil;
import com.zjdiepu.www.util.HtmlUtil;

/**
 * 工商银行：中转服务器请求主程序接口业务实现
 * @update xiongxiaotun
 */
@Service
public class IcbcApiServiceImpl implements IcbcApiService {
	private Logger logger = LoggerFactory.getLogger(getClass());
	@Autowired
	private PublicDao publicDao;
	
	@Autowired
	private OtherLoanLossProvisionMapper otherLoanLossProvisionMapper;
	
	@Autowired
	private ZxCreditQueryMapper zxCreditQueryHzicbcMapper;
	
	@Autowired
	private ZxCreditQueryMapper zxCreditQueryMapper;
	
	@Autowired
	private ZxQueryCreditApplyMapper zxQueryCreditApplyMapper;
	 
	@Autowired
	private ZxQueryCreditApplySubMapper zxQueryCreditApplySubMapper;
	
	@Autowired
	private YwShenQingZxService ywShenQingZxService;
	
	@Autowired
	private OwnDiepuService ownDiepuService;
	
	@Autowired
	private YwBusinessMapper ywBusinessMapper;
	
	@Autowired
	private OtherAttachmentsMapper otherAttachmentsMapper;
	
	@Autowired
	private SystemService systemService;
	
	@Autowired
	private BaseSalersmanMapper baseSalersmanMapper;
	
	@Autowired
	private ISerialNumberService serialNumberService;
	
	@Autowired
	private BaseCustomerMapper baseCustomerMapper;
	
	@Resource
	private IPhoneNumberAddrService phoneNubmerAddrService;
	
	@Autowired
	private YwBusinessBuyerMapper ywBusinessBuyerMapper; 
	
	@Autowired
	private YwOrdernoBankMapper ywOrdernoBankMapper;
	
	
	@Override
	public void diepuUpdateRiskReserve(SysUser currentUser,OtherLoanLossProvision otherLoanLossProvision)
	{
		
		if(null == currentUser)
		{
			throw new BaseException(ResultFlagType.LOGIN_TIMEOUT.getCode().toString(),ResultFlagType.LOGIN_TIMEOUT.getValue());
		}
		String userId = currentUser.getId();
		String loginName = currentUser.getUname();
		if(StringUtils.isBlank(userId) || StringUtils.isBlank(loginName))
		{
			throw new BaseException(ResultFlagType.LOGIN_TIMEOUT.getCode().toString(),ResultFlagType.LOGIN_TIMEOUT.getValue());
		}
		
		if(null == otherLoanLossProvision)
		{
			throw new BaseException(ResultFlagType.PARAM_EMPTY.getCode().toString(),ResultFlagType.PARAM_EMPTY.getValue());
		}
		otherLoanLossProvision.setBank("ICBC");
		OtherLoanLossProvision provision = new OtherLoanLossProvision();
		provision.setBank(otherLoanLossProvision.getBank());
		provision.setInstcode(otherLoanLossProvision.getInstcode());
		provision.setAccno(otherLoanLossProvision.getAccno());
		provision.setSubAccno(otherLoanLossProvision.getSubAccno());
		provision.setDpStatus(1);
		provision = otherLoanLossProvisionMapper.selectRefined(provision);
		if(null == provision)
		{
			otherLoanLossProvision.initInsertData(userId, loginName);
			int count = otherLoanLossProvisionMapper.insert(otherLoanLossProvision);
			if(count < 1)
			{
				throw new BaseException(ResultFlagType.FAIL.getCode().toString(),"otherLoanLossProvisionMapper insert error");
			}
		}
		
		if(null != provision)
		{
			int count = otherLoanLossProvisionMapper.deleteByPrimaryKey(provision.getId());
			if(count < 1)
			{
				throw new BaseException(ResultFlagType.FAIL.getCode().toString(),"otherLoanLossProvisionMapper deleteByPrimaryKey error");
			}
			
			otherLoanLossProvision.initInsertData(userId, loginName);
			count = otherLoanLossProvisionMapper.insert(otherLoanLossProvision);
			if(count < 1)
			{
				throw new BaseException(ResultFlagType.FAIL.getCode().toString(),"otherLoanLossProvisionMapper insert error");
			}
		}
	}


	@Override
	public void diepuCreditResult(SysUser currentUser, CreditResultRequest creditResultRequest) throws Exception {
		
		CreditResultInfo creditResultInfo = creditResultRequest.getReq();
		if(null == creditResultInfo) {
			throw new BaseException(ResultFlagType.PARAM_EMPTY.getCode().toString(),"征信结果对象为空");
		}
		
		String result = creditResultInfo.getResult();
		if(StringUtils.isBlank(result)) {
			throw new BaseException(ResultFlagType.PARAM_EMPTY.getCode().toString(),"征信结果状态为空");
		}
		
		String orderno = creditResultRequest.getPub().getOrderno();
		if(StringUtils.isBlank(orderno)) {
			throw new BaseException(ResultFlagType.PARAM_EMPTY.getCode().toString(),"银行订单号为空");
		}
		
		String relation = creditResultInfo.getRelation();
		if(StringUtils.isBlank(relation)) {
			throw new BaseException(ResultFlagType.PARAM_EMPTY.getCode().toString(),"申请征信客户角色为空");
		}
		
		//判断集合是不是空
		if(null == creditResultRequest.creditApplies || creditResultRequest.creditApplies.size() == 0) {
			throw new BaseException(ResultFlagType.PARAM_EMPTY.getCode().toString(),"征信反馈申请记录为空");
		}
		
		String custname = creditResultInfo.getCustname();
		String idno = creditResultInfo.getIdno();
		String loanCrdt = creditResultInfo.getLoanCrdt();
		String cardCrdt = creditResultInfo.getCardCrdt();
		String leftNum = creditResultInfo.getLeftNum();
		String leftAmount = creditResultInfo.getLeftAmount();
		
		//征信反馈结果
		String note = creditResultInfo.getNote();
		if(StringUtils.isBlank(note) || "-".equals(note)) { 
			note = "工行备注为空，碟普提示";
		}
		
		String creditPeopleType = "";
		if(RelationType.BEN_REN.getCode().equals(relation)) {
			creditPeopleType = CreditPeopleType.ZHU_JIE_REN.getCode();
		} else if(RelationType.PEI_OU.getCode().equals(relation)) {
			creditPeopleType = CreditPeopleType.PEI_OU.getCode();
		} else if(RelationType.FAN_DAN_BAO.getCode().equals(relation)) {
			creditPeopleType = CreditPeopleType.DAN_BAO_REN.getCode();
		}
		
		for(CreditApply creditApply : creditResultRequest.creditApplies) {
			String queryCreditApplyId = creditApply.getQueryCreditApplyId();
			String queryCreditApplySubId = creditApply.getQueryCreditApplySubId();
			
			if(StringUtils.isBlank(queryCreditApplyId)) {
				logger.error("征信结果反馈，有客户申请ID参数为空。单号：{}，客户：{}， 身份证号：{}。", orderno, custname, idno);
				continue;
			}
			
			DiepuCreditFeedbackExt diepuCreditFeedbackExt = new  DiepuCreditFeedbackExt();
			diepuCreditFeedbackExt.setResult(result);
			diepuCreditFeedbackExt.setCreditPeopleType(creditPeopleType);
			
			if(BankCreditResultType.ZHENG_CHANG.getCode().equals(result) 
					|| BankCreditResultType.GUAN_ZHU.getCode().equals(result) 
					|| BankCreditResultType.JIN_RU.getCode().equals(result)) {
				if(BankCreditResultType.ZHENG_CHANG.getCode().equals(result)) {
					diepuCreditFeedbackExt.setCreditResult(CreditResult.NOMAL.getCode());
				} else if(BankCreditResultType.GUAN_ZHU.getCode().equals(result)) {
					diepuCreditFeedbackExt.setCreditResult(CreditResult.FOCUS.getCode());
				} else if(BankCreditResultType.JIN_RU.getCode().equals(result)) {
					diepuCreditFeedbackExt.setCreditResult(CreditResult.DEBAR.getCode());
				}
				
				diepuCreditFeedbackExt.setOnceCarStatus("-");
				Date now = new Date();
				diepuCreditFeedbackExt.setStartDate(now);
				diepuCreditFeedbackExt.setEndDate(DateUtil.increaseDate(now, 30));
				diepuCreditFeedbackExt.setLoanCrdt(loanCrdt);
				diepuCreditFeedbackExt.setCardCrdt(cardCrdt);
				diepuCreditFeedbackExt.setLeftAmount(leftAmount);
				diepuCreditFeedbackExt.setLeftNum(leftNum);
			}
			
			diepuCreditFeedbackExt.setCreditResultMark(note);
			diepuCreditFeedbackExt.setQueryCreditApplyId(queryCreditApplyId);
			
//			@update 2018-02-27 增加身份证和子申请id
			diepuCreditFeedbackExt.setCustName(custname);
			diepuCreditFeedbackExt.setCusNo(idno);
			diepuCreditFeedbackExt.setCreditApplySubId(queryCreditApplySubId);
			YwBusiness ywBusiness = diepuCreditFeedback(currentUser,diepuCreditFeedbackExt);
			if(CreditPeopleType.ZHU_JIE_REN.getCode().equals(creditPeopleType)) {
				if(null == ywBusiness) {
					return;
				}
				
				YwOrdernoBank ywOrdernoBankParam = new YwOrdernoBank();
				ywOrdernoBankParam.setQueryCreditApplyId(queryCreditApplyId);
				ywOrdernoBankParam.setOrdeRno(orderno);
				ywOrdernoBankParam.setDpStatus(DpStatus.NORMAL.getCode());
				ywOrdernoBankParam.setTypeData(TypeData.HZICBC.getCode());
				ywOrdernoBankParam = ywOrdernoBankMapper.selectRefined(ywOrdernoBankParam);
				if(null == ywOrdernoBankParam) {
					logger.error("银行订单号丢失。订单号：{}，申请ID：{}。",orderno, queryCreditApplyId);
					throw new BaseException(ResultFlagType.PARAM_EMPTY.getCode().toString(),"{ywOrdernoBankMapper selectRefined is null}");
				}
				YwOrdernoBank ywOrdernoBank = new YwOrdernoBank(); //只修改BUSI_ID
				ywOrdernoBank.setId(ywOrdernoBankParam.getId()); 
				ywOrdernoBank.initUpdateData(currentUser.getId(), currentUser.getName());
				ywOrdernoBank.setBusiId(ywBusiness.getId());
				ywOrdernoBankMapper.updateByPrimaryKeySelective(ywOrdernoBank);
				
				DiepuZxQuerySuccessBusiIdUpRequest diepuZxQuerySuccessBusiIdUpRequest = new DiepuZxQuerySuccessBusiIdUpRequest();
    			diepuZxQuerySuccessBusiIdUpRequest.setId(queryCreditApplyId);
    			diepuZxQuerySuccessBusiIdUpRequest.setBusiId(ywBusiness.getId());
    			BooleanResponse booleanResponse = ownDiepuService.diepuZxQuerySuccessBusiIdUp(diepuZxQuerySuccessBusiIdUpRequest, Partners.HZ_ICBC);
    			if(!Optional.ofNullable(booleanResponse).map(item -> item.getResult()).orElse(false)) {
    				throw new BaseException(ResultFlagType.FAIL.getCode().toString(),"BooleanResponse result false {ownDiepuService.diepuZxQuerySuccessBusiIdUp(diepuZxQuerySuccessBusiIdUpRequest, Partners.HZ_ICBC)}");
    			}
			}
		}
	}
	
	@Override
	public List<ObtainFileList> diepuObtainFileList(SysUser currentUser,ObtainFileListRequest obtainFileListRequest) throws Exception {
		if(null == obtainFileListRequest)
		{
			throw new BaseException(ResultFlagType.PARAM_EMPTY.getCode().toString(),"obtainFileListRequest is null");
		}
		
		if(null == obtainFileListRequest.otherList || 0 == obtainFileListRequest.otherList.size())
		{
			throw new BaseException(ResultFlagType.PARAM_EMPTY.getCode().toString(),"obtainFileListRequest.otherList is null {obtainFileListRequest.otherList.size = 0}");
		}
		
		List<ObtainFileList> obtainFileLists = new ArrayList<ObtainFileList>();
		for(int i=0;i<obtainFileListRequest.otherList.size();i++)
		{
			OtherAttachmentsExt otherAttachmentsExt = new OtherAttachmentsExt();
			otherAttachmentsExt.withOutPage();
			otherAttachmentsExt.setDataid(obtainFileListRequest.otherList.get(i).getDataId());
			otherAttachmentsExt.setModeId(obtainFileListRequest.otherList.get(i).getModeId());
			otherAttachmentsExt.setDpStatus(1);
			List<OtherAttachments> list = otherAttachmentsMapper.selectByExt(otherAttachmentsExt);
			if(null == list || 0 == list.size())
			{
				throw new BaseException(ResultFlagType.PARAM_EMPTY.getCode().toString(),"otherAttachmentsMapper  selectByExt is null {otherAttachmentsMapper.selectByExt.size = 0}");
			}
			
			for(int j=0;j<list.size();j++)
			{
				ObtainFileList obtainFileList = new ObtainFileList();
				BeanUtils.copyProperties(list.get(j), obtainFileList);
				obtainFileList.setTypeData(3);
				obtainFileList.setFileHandleStatus("10");
				obtainFileList.setBankOrderNo(obtainFileListRequest.otherList.get(i).getBankOrderNo());
				obtainFileList.setLocalFilePath(list.get(j).getOssPath());
				obtainFileLists.add(obtainFileList);
			}
		}
		return obtainFileLists;
	}


	@Override
	public YwBusiness diepuCreditFeedback(AbstractSysUser currentUser,DiepuCreditFeedbackExt diepuCreditFeedbackExt) throws Exception  {
		//插入业务信息表数据
		YwBusiness ywBusiness = null;
		Date now = new Date();
		String result = diepuCreditFeedbackExt.getResult();
		String creditPeopleType = diepuCreditFeedbackExt.getCreditPeopleType();
		String queryCreditApplyId = diepuCreditFeedbackExt.getQueryCreditApplyId();
		String creditResult = diepuCreditFeedbackExt.getCreditResult();
		String cusNo = diepuCreditFeedbackExt.getCusNo();
		String userId = currentUser.getId();
		String logName = currentUser.getName();
		
		//2018-03-07 定位唯一申请客户(工行返回的结果使用cusNo定位，中间服务业务判断后返回的使用creditApplySubId) 取代 以前的使用申请id和角色，担保人征信结果错乱问题终结
		String creditApplySubId = diepuCreditFeedbackExt.getCreditApplySubId();
		String sqlXmls = null;
		if(StringUtils.isNotBlank(creditApplySubId)) {
			sqlXmls = "select q.id queryId,sub.query_credit_apply_id queryCreditApplyId,sub.id queryCreditApplyIdSub from zx_query_credit_apply_sub sub left join zx_credit_query q on q.query_credit_apply_sub_id = sub.id where sub.dp_status = 1 and sub.dp_status = 1 and sub.type_data = 3 and sub.id = '" + creditApplySubId + "'";
		} else {
			sqlXmls = "select q.id queryId,sub.query_credit_apply_id queryCreditApplyId,sub.id queryCreditApplyIdSub from zx_query_credit_apply_sub sub left join zx_credit_query q on q.query_credit_apply_sub_id = sub.id where sub.dp_status = 1 and sub.dp_status = 1 and sub.type_data = 3 and sub.cus_no = '" + cusNo + "'";
		}
		List<Map<String, String>> reuslt = publicDao.queryWhereSql(sqlXmls);
		if(CollectionUtils.isNotEmpty(reuslt)) {
			Map<String, String> map = reuslt.get(0);
			String queryId = map.get("queryId");
			queryCreditApplyId = map.get("queryCreditApplyId");
			creditApplySubId = map.get("queryCreditApplyIdSub");
			
			if(BankCreditResultType.TUI_HUI.getCode().equals(result)) { //退回，如果工行返回的result（客户信用等级） 为 099
				ZxQueryCreditApply zxQueryCreditApply = new ZxQueryCreditApply();
				zxQueryCreditApply.initUpdateData(userId, logName);
				zxQueryCreditApply.setId(queryCreditApplyId);
				zxQueryCreditApply.setQueryCreditApplyStatus(QueryCreditApplyStatus.TUI_HUI.getCode());
				int count = zxQueryCreditApplyMapper.updateByPrimaryKeySelective(zxQueryCreditApply);
				if(count < 1) {
					logger.error("征信申请记录丢失。申请ID：{}。", queryCreditApplyId);
					throw new BaseException(ResultFlagType.MISSING.getCode().toString(),"征信申请记录丢失");
				}
				
				ZxQueryCreditApplySub zxQueryCreditApplySub = new ZxQueryCreditApplySub();
				zxQueryCreditApplySub.initUpdateData(userId, logName);
				zxQueryCreditApplySub.setId(creditApplySubId);
				zxQueryCreditApplySub.setReasonBack(diepuCreditFeedbackExt.getResult());
				count = zxQueryCreditApplySubMapper.updateByPrimaryKeySelective(zxQueryCreditApplySub);
				if(count < 1) {
					logger.error("征信子申请记录丢失。申请ID：{}，子申请ID:{}。", queryCreditApplyId, creditApplySubId);
					throw new BaseException(ResultFlagType.MISSING.getCode().toString(),"征信子申请记录丢失");
				}
				
				ZxCreditQuery zxCreditQuery = new ZxCreditQuery();
				zxCreditQuery.initUpdateData(userId, logName);
				zxCreditQuery.setId(queryId);
				zxCreditQuery.setStartDate(diepuCreditFeedbackExt.getStartDate());
				zxCreditQuery.setOperatorDate(diepuCreditFeedbackExt.getStartDate());
				zxCreditQuery.setEndDate(diepuCreditFeedbackExt.getEndDate());
				zxCreditQuery.setCreditResult(diepuCreditFeedbackExt.getCreditResult());
				zxCreditQuery.setCreditResultMark(diepuCreditFeedbackExt.getCreditResultMark());
				//2018-02-02 xiongxt 解析说明字段
				parseMark(zxCreditQuery);
				zxCreditQuery.setOnceCarStatus(diepuCreditFeedbackExt.getOnceCarStatus());
				zxCreditQuery.setCreditQueryStatus(CreditQueryStatus.TUI_HUI.getCode());
				zxCreditQuery.setRemarks(diepuCreditFeedbackExt.getCreditResultMark());
				count = zxCreditQueryMapper.updateByPrimaryKeySelective(zxCreditQuery);
				if(count < 1) {
					logger.error("征信结果记录丢失。申请ID：{}，子申请ID:{}，子征信结果ID：{}。", queryCreditApplyId, creditApplySubId, queryId);
					throw new BaseException(ResultFlagType.MISSING.getCode().toString(),"征信结果记录丢失");
				}
				systemService.diepuNewsHandle(currentUser, ModeIDType.ZXCX.getCode(), NewsType.TZ01.getCode(), null,creditApplySubId, queryId);
			} else if(BankCreditResultType.JIN_RU.getCode().equals(result)) { //禁入
				ZxQueryCreditApply zxQueryCreditApply = new ZxQueryCreditApply();
				zxQueryCreditApply.initUpdateData(userId, logName);
				zxQueryCreditApply.setId(queryCreditApplyId);
				zxQueryCreditApply.setQueryCreditApplyStatus(QueryCreditApplyStatus.TI_JIAO.getCode());
				int count = zxQueryCreditApplyMapper.updateByPrimaryKeySelective(zxQueryCreditApply);
				if(count < 1) {
					logger.error("征信申请记录丢失。申请ID：{}。", queryCreditApplyId);
					throw new BaseException(ResultFlagType.MISSING.getCode().toString(),"征信申请记录丢失");
				}
				
				ZxQueryCreditApplySub zxQueryCreditApplySub = new ZxQueryCreditApplySub();
				zxQueryCreditApplySub.initUpdateData(userId, logName);
				zxQueryCreditApplySub.setId(creditApplySubId);
				zxQueryCreditApplySub.setCcol2(result);
				Integer ccol3 = ZhppDateUtil.dateConvertStamp();
				zxQueryCreditApplySub.setCcol3(String.valueOf(ccol3));
				count = zxQueryCreditApplySubMapper.updateByPrimaryKeySelective(zxQueryCreditApplySub);
				if(count < 1) {
					logger.error("征信子申请记录丢失。申请ID：{}，子申请ID:{}。", queryCreditApplyId, creditApplySubId);
					throw new BaseException(ResultFlagType.MISSING.getCode().toString(),"征信子申请记录丢失");
				}
				
				ZxCreditQuery zxCreditQuery = new ZxCreditQuery();
				zxCreditQuery.initUpdateData(userId, logName);
				zxCreditQuery.setId(queryId);
				zxCreditQuery.setStartDate(diepuCreditFeedbackExt.getStartDate());
				zxCreditQuery.setOperatorDate(diepuCreditFeedbackExt.getStartDate());
				zxCreditQuery.setEndDate(diepuCreditFeedbackExt.getEndDate());
				zxCreditQuery.setCreditResult(diepuCreditFeedbackExt.getCreditResult());
				zxCreditQuery.setCreditResultMark(diepuCreditFeedbackExt.getCreditResultMark());
				//2018-02-02 xiongxt 解析说明字段
				parseMark(zxCreditQuery);
				zxCreditQuery.setOnceCarStatus(diepuCreditFeedbackExt.getOnceCarStatus());
				zxCreditQuery.setCreditQueryStatus(CreditQueryStatus.YI_CHA_XUN.getCode());
				zxCreditQuery.setRemarks(diepuCreditFeedbackExt.getCreditResultMark());
				count = zxCreditQueryMapper.updateByPrimaryKeySelective(zxCreditQuery);
				if(count < 1) {
					logger.error("征信结果记录丢失。申请ID：{}，子申请ID:{}，子征信结果ID：{}。", queryCreditApplyId, creditApplySubId,queryId);
					throw new BaseException(ResultFlagType.MISSING.getCode().toString(),"征信结果记录丢失");
				}
				//主借人推送拒单消息
				systemService.diepuNewsHandle(currentUser, ModeIDType.ZXCX.getCode(), NewsType.TZ02.getCode(), null, creditApplySubId, queryId);
			} else if(BankCreditResultType.ZHENG_CHANG.getCode().equals(result) || BankCreditResultType.GUAN_ZHU.getCode().equals(result)) { //正常关注
				//担保人或者配偶
				if(CreditPeopleType.DAN_BAO_REN.getCode().equals(creditPeopleType) || CreditPeopleType.PEI_OU.getCode().equals(creditPeopleType)) {
					ZxQueryCreditApply zxQueryCreditApply = new ZxQueryCreditApply();
					zxQueryCreditApply.initUpdateData(userId, logName);
					zxQueryCreditApply.setId(queryCreditApplyId);
					zxQueryCreditApply.setQueryCreditApplyStatus(QueryCreditApplyStatus.TI_JIAO.getCode());
					int count = zxQueryCreditApplyMapper.updateByPrimaryKeySelective(zxQueryCreditApply);
					if(count < 1) {
						logger.error("征信申请记录丢失。申请ID：{}。", queryCreditApplyId);
						throw new BaseException(ResultFlagType.MISSING.getCode().toString(),"征信申请记录丢失");
					}
					
					ZxQueryCreditApplySub zxQueryCreditApplySub = new ZxQueryCreditApplySub();
					zxQueryCreditApplySub.initUpdateData(userId, logName);
					zxQueryCreditApplySub.setId(creditApplySubId);
					zxQueryCreditApplySub.setCcol2(BankCreditResultType.ZHENG_CHANG.getCode());
					
//					@update 2018-04-04
					zxQueryCreditApplySub.setQueryStatus(CreditQueryStatus.YI_CHA_XUN.getCode());
					zxQueryCreditApplySub.setCcol3(String.valueOf(DateUtil.truncAndAddDays(now, 0).getTime() / 1000));
					count = zxQueryCreditApplySubMapper.updateByPrimaryKeySelective(zxQueryCreditApplySub);
					if(count < 1) {
						logger.error("征信子申请记录丢失。申请ID：{}，子申请ID:{}。", queryCreditApplyId, creditApplySubId);
						throw new BaseException(ResultFlagType.MISSING.getCode().toString(),"征信子申请记录丢失");
					}
					
					ZxCreditQuery zxCreditQuery = new ZxCreditQuery();
					zxCreditQuery.initUpdateData(userId, logName);
					zxCreditQuery.setId(queryId);
					zxCreditQuery.setStartDate(diepuCreditFeedbackExt.getStartDate());
					zxCreditQuery.setOperatorDate(diepuCreditFeedbackExt.getStartDate());
					zxCreditQuery.setEndDate(diepuCreditFeedbackExt.getEndDate());
					zxCreditQuery.setCreditResult(diepuCreditFeedbackExt.getCreditResult());
					zxCreditQuery.setCreditResultMark(diepuCreditFeedbackExt.getCreditResultMark());
					//2018-02-02 xiongxt 解析说明字段
					parseMark(zxCreditQuery);
					zxCreditQuery.setOnceCarStatus(diepuCreditFeedbackExt.getOnceCarStatus());
					zxCreditQuery.setCreditQueryStatus(CreditQueryStatus.YI_CHA_XUN.getCode());
					zxCreditQuery.setRemarks(diepuCreditFeedbackExt.getCreditResultMark());
					count = zxCreditQueryMapper.updateByPrimaryKeySelective(zxCreditQuery);
					if(count < 1) {
						logger.error("征信结果记录丢失。申请ID：{}，子申请ID:{}，子征信结果ID：{}。", queryCreditApplyId, creditApplySubId,queryId);
						throw new BaseException(ResultFlagType.MISSING.getCode().toString(),"征信结果记录丢失");
					}
				} else if(CreditPeopleType.ZHU_JIE_REN.getCode().equals(creditPeopleType)) { //主借人
					ZxCreditQuery zxCreditQuery = null;
					if(CreditResult.NOMAL.getCode().equals(creditResult) || CreditResult.FOCUS.getCode().equals(creditResult)) {
						ZxQueryCreditApply zxQueryCreditApply = new ZxQueryCreditApply();
						zxQueryCreditApply.initUpdateData(userId, logName);
						zxQueryCreditApply.setId(queryCreditApplyId);
						zxQueryCreditApply.setQueryCreditApplyStatus(QueryCreditApplyStatus.TI_JIAO.getCode());
						int count = zxQueryCreditApplyMapper.updateByPrimaryKeySelective(zxQueryCreditApply);
						if(count < 1) {
							logger.error("征信申请记录丢失。申请ID：{}。", queryCreditApplyId);
							throw new BaseException(ResultFlagType.MISSING.getCode().toString(),"征信申请记录丢失");
						}
					
						ZxQueryCreditApplySub zxQueryCreditApplySub = new ZxQueryCreditApplySub();
						zxQueryCreditApplySub.initUpdateData(userId, logName);
						zxQueryCreditApplySub.setId(creditApplySubId);
						zxQueryCreditApplySub.setReasonBack(diepuCreditFeedbackExt.getReasonBack());
						zxQueryCreditApplySub.setCcol2(BankCreditResultType.ZHENG_CHANG.getCode());
						
//						@update 2018-04-04
						zxQueryCreditApplySub.setQueryStatus(CreditQueryStatus.YI_CHA_XUN.getCode());
						
						zxQueryCreditApplySub.setCcol3(String.valueOf(DateUtil.truncAndAddDays(now, 0).getTime() / 1000));
						count = zxQueryCreditApplySubMapper.updateByPrimaryKeySelective(zxQueryCreditApplySub);
						if(count < 1) {
							logger.error("征信子申请记录丢失。申请ID：{}，子申请ID:{}。", queryCreditApplyId, creditApplySubId);
							throw new BaseException(ResultFlagType.MISSING.getCode().toString(),"征信子申请记录丢失");
						}
						
						zxCreditQuery = new ZxCreditQuery();
						zxCreditQuery.initUpdateData(userId, logName);
						zxCreditQuery.setId(queryId);
						zxCreditQuery.setStartDate(diepuCreditFeedbackExt.getStartDate());
						zxCreditQuery.setOperatorDate(diepuCreditFeedbackExt.getStartDate());
						zxCreditQuery.setEndDate(diepuCreditFeedbackExt.getEndDate());
						zxCreditQuery.setCreditResult(diepuCreditFeedbackExt.getCreditResult());
						zxCreditQuery.setCreditResultMark(diepuCreditFeedbackExt.getCreditResultMark());
						//2018-02-02 xiongxt 解析说明字段
						parseMark(zxCreditQuery);
						zxCreditQuery.setOnceCarStatus(diepuCreditFeedbackExt.getOnceCarStatus());
						zxCreditQuery.setCreditQueryStatus(CreditQueryStatus.YI_CHA_XUN.getCode());
						zxCreditQuery.setRemarks(diepuCreditFeedbackExt.getCreditResultMark());
						count = zxCreditQueryMapper.updateByPrimaryKeySelective(zxCreditQuery);
						if(count < 1) {
							logger.error("征信结果记录丢失。申请ID：{}，子申请ID:{}，子征信结果ID：{}。", queryCreditApplyId, creditApplySubId,queryId);
							throw new BaseException(ResultFlagType.MISSING.getCode().toString(),"征信结果记录丢失");
						}
						
						//查询征信 主表的数据
					    zxQueryCreditApply =  zxQueryCreditApplyMapper.selectByPrimaryKey(queryCreditApplyId);
					    
					    //查询业务员表数据信息
					    String salersmanIdThen = zxQueryCreditApply.getSalersmanIdThen();
						BaseSalersman baseSalersman = baseSalersmanMapper.selectByPrimaryKey(salersmanIdThen);
						if(null == baseSalersman) {
							logger.error("业务员记录丢失。业务员ID：{}。", salersmanIdThen);
							throw new BaseException(ResultFlagType.PARAM_EMPTY.getCode().toString(),"业务员记录丢失");
						}
						
						//客户信息
						BaseCustomer baseCustomer = new BaseCustomer();
				    	baseCustomer.initInsertData(userId, logName);
				    	baseCustomer.setTypeData(TypeData.HZICBC.getCode());
						baseCustomer.setSalesmanId(baseSalersman.getId());
						baseCustomer.setSalesmanCode(baseSalersman.getSalersmanCode());
						baseCustomer.setSalesmanName(baseSalersman.getName());
						baseCustomer.setName(baseSalersman.getName());
						
						//客户编号规则：KH+8位序号
						String cus_code = "C" + DateUtil.dateTo8Str(now) + new DecimalFormat("0000").format(serialNumberService.createSerialNumber(CodeType.CUSTOMER,null, false));
						//客户编号规则：KH+8位序号
						
						baseCustomer.setCusCode(cus_code);
						baseCustomer.setCusNo(zxQueryCreditApply.getCustomerNo());
						baseCustomer.setCusNo2(zxQueryCreditApply.getCustomerNo2());
						
						count = baseCustomerMapper.insert(baseCustomer);
						
						//客户编号
						zxQueryCreditApply.setCustomerId(baseCustomer.getId());
						
						ywBusiness = new YwBusiness();
						ywBusiness.initInsertData(userId, logName);
						ywBusiness.setTypeData(TypeData.HZICBC.getCode());
						
						//生成编码
						String busiCode = DateUtil.dateTo8Str(now) + new DecimalFormat("00000000").format(serialNumberService.createSerialNumber(CodeType.BUSINESS,null, true));
						ywBusiness.setBusiCode(busiCode);
						ywBusiness.setQueryCreditApplyId(queryCreditApplyId);  
						ywBusiness.setCreditQueryId(queryId);  
						ywBusiness.setDealerId(zxQueryCreditApply.getDealerId());
						ywBusiness.setCustomerId(baseCustomer.getId());
						ywBusiness.setCustomerName(zxQueryCreditApply.getCustomerName());
						ywBusiness.setCustomerNo(zxQueryCreditApply.getCustomerNo());
						
						//料登记10
						ywBusiness.setBusiStatus(BusiStatus.ZI_LIAO_DENG_JI.getCode());  
						//业务电审状态10
						ywBusiness.setPhoneStatus(PhoneStatus.NOT_PHONE.getCode()); 
						//通道状态无
						ywBusiness.setChannelStatus(10);
						//通融状态通融
						ywBusiness.setTongrongStatus(TongrongStatus.NOT_TONGRONG.getCode());
						//额外状态1未定级
						ywBusiness.setAddedStatus1(AddedStatus1.AN_JIE_RI_BAO_BIAO_WEI_DENG_JI.getCode());
						//欠资料状态
						ywBusiness.setLessInformationStatus(LessInformationStatus.ZI_LIAO_QI_QUAN.getCode());  
						//归档状态为
						ywBusiness.setStatusArchive(ArchiveStatus.UN_ARCHIVE.getCode());
						//所处银行
						ywBusiness.setBankLoan(zxQueryCreditApply.getBankCode());
						//业务员id 
						ywBusiness.setSalesmanId(baseSalersman.getId());
						//业务员编码 
						ywBusiness.setSalesmanCode(baseSalersman.getSalersmanCode());
						
						//查询征信结果表
						zxCreditQuery = zxCreditQueryMapper.selectByPrimaryKey(queryId);
						//征信录入时间
						ywBusiness.setOperatorDate(zxCreditQuery.getOperatorDate());
						//业务录入时间
						ywBusiness.setSubmitTime(now);
						//业务表执行添加
						ywBusinessMapper.insert(ywBusiness);
						
						//业务编号
						zxQueryCreditApply.setBusiId(ywBusiness.getId());
						//修改征信主表
						count = zxQueryCreditApplyMapper.updateByPrimaryKeySelective(zxQueryCreditApply);
						//业务编号
						zxCreditQuery.setBusiId(ywBusiness.getId());
						//客户编号
						zxCreditQuery.setCustomerId(baseCustomer.getId());
						
						if(null != diepuCreditFeedbackExt.getLeftAmount()) {
							try {
								zxCreditQuery.setLeftAmount(Double.valueOf(diepuCreditFeedbackExt.getLeftAmount()));
							} catch(NumberFormatException e) {
								logger.error("IcbcApiServiceImpl.diepuCreditFeedback happend number format exception. leftAmount is {}.", diepuCreditFeedbackExt.getLeftAmount());
							}
						}
							
						if(null != diepuCreditFeedbackExt.getLeftNum()) {
							try {
								zxCreditQuery.setLeftNum(Integer.valueOf(diepuCreditFeedbackExt.getLeftNum()));
							} catch(NumberFormatException e) {
								logger.error("IcbcApiServiceImpl.diepuCreditFeedback happend number format exception. leftNum is {}.",  diepuCreditFeedbackExt.getLeftNum());
							}
						}
						zxCreditQuery.setLoanCrdt(diepuCreditFeedbackExt.getLoanCrdt());
						zxCreditQuery.setCardCrdt(diepuCreditFeedbackExt.getCardCrdt());
						
						//征信结果表修改
						zxCreditQueryMapper.updateByPrimaryKeySelective(zxCreditQuery);
						
						//查询征信结果表
						sqlXmls = "select t.id as applySubId ,q.id as queryId,t.credit_people_type,t.cus_name,t.cus_no,t.tel1 from zx_query_credit_apply_sub t join zx_credit_query q on t.id = q.query_credit_apply_sub_id where t.query_credit_apply_id = '"+queryCreditApplyId+"' and t.dp_status = 1 and t.type_data = 3";
//						sqlXmls = "select t.id ,t.credit_people_type,t.cus_name,t.cus_no,t.tel1 from zx_query_credit_apply_sub t where t.query_credit_apply_id = '"+queryCreditApplyId+"' and t.dp_status = 1 and t.type_data = 3";
						List<Map<String, String>> items = publicDao.queryWhereSql(sqlXmls);
						if(CollectionUtils.isEmpty(items)) {
							logger.error("征信结果记录丢失。申请ID：{}。", queryCreditApplyId);
							throw new BaseException(ResultFlagType.MISSING.getCode().toString(),"征信结果记录丢失");
						}
						
//						@update 有历史订单时更新结果和子申请的busiId
						String busiId = ywBusiness.getId();
						
						for(Map<String, String> item : items) {
							creditPeopleType = item.get("credit_people_type");
							String cusName = item.get("cus_name");
							String cusNoItem = item.get("cus_no");
							String tel1 = item.get("tel1");
							
							//update 2018-04-04 历史记录生成的订单，生成结果表busiId填充
							String itemQueryId = item.get("queryId");
							ZxCreditQuery zxCreditQueryItem = new ZxCreditQuery();
							zxCreditQueryItem.initUpdateData(userId, logName);
							zxCreditQueryItem.setId(itemQueryId);
							zxCreditQueryItem.setBusiId(busiId);
							zxCreditQueryItem.setCustomerId(baseCustomer.getId());
							zxCreditQueryMapper.updateByPrimaryKeySelective(zxCreditQueryItem);
							
							YwBusinessBuyer ywBusinessBuyer = new YwBusinessBuyer();
							ywBusinessBuyer.initInsertData(userId, logName); 
							ywBusinessBuyer.setTypeData(TypeData.HZICBC.getCode());
							ywBusinessBuyer.setCarManType(creditPeopleType);
							ywBusinessBuyer.setBusiId(busiId);
							ywBusinessBuyer.setCusId(ywBusiness.getCustomerId());
							ywBusinessBuyer.setName(cusName);
							ywBusinessBuyer.setIdno(cusNoItem);
							ywBusinessBuyer.setIdno2(cusNoItem);
							ywBusinessBuyer.setTel1(tel1);
							
							//获取户籍信息
							Map<String,Object> jsonMaps = phoneNubmerAddrService.getIdCordInfo(cusNoItem);
							if(MapUtils.isNotEmpty(jsonMaps)) {
								JSONObject json = CommonUtil.getJSONObject(jsonMaps.get("result"));	
								int isok = json.getInt("isok");
								if(isok != -1) {
									ywBusinessBuyer.setArea(String.valueOf(json.get("area")));
									ywBusinessBuyer.setSex("男".equals(json.getString("sex")) ? "01" : "02");
									ywBusinessBuyer.setFamilyRegister(String.valueOf(json.get("province")));
								}
							}
							ywBusinessBuyerMapper.insert(ywBusinessBuyer);
						}
					}
				}
				//调用发送短信推送接口
//				@update 2018-03-05 添加征信结果ID，统一发送结果（担保人和配偶分支的发送已删除，统一到当前位置）
				systemService.diepuNewsHandle(currentUser, ModeIDType.ZXCX.getCode(), NewsType.TZ03.getCode(),null != ywBusiness ? ywBusiness.getId(): null,creditApplySubId, queryId);
			}
		}
		return ywBusiness;
	}
	
	/**
	 * 解析查询结果说明
	 * @author xiongxiaotun <br/>
	 * @Title parseMark  <br/>
	 * @Description 解析查询结果说明 <br/>
	 * @param zxCreditQuery
	 * @version V1.0  <br/>
	 */
	public static void parseMark(ZxCreditQuery zxCreditQuery) {
		String creditResultMark = zxCreditQuery.getCreditResultMark();
		if(StringUtils.isBlank(creditResultMark)) {
			return;
		}
		creditResultMark = HtmlUtil.filterHtml(creditResultMark).trim().replaceAll(" ", "");
		String[] marks = creditResultMark.split("((?=贷款汇总\\(抵押\\))|(?=贷款汇总\\(信用\\))|(?=信用卡汇总)|(?=备注)|(?=对外担保))");
		String dy = "贷款汇总(抵押):";
		String xy = "贷款汇总(信用):";
		String xyk = "信用卡汇总:";
		String dwdb = "对外担保:";
		String bz = "备注:";
		
		String wjqdkbs = "未结清贷款笔数:";
		String wjqdkye = "未结清贷款余额:";
		String jlgypjyh =  "近6个月平均月还:";
		
		String jlnyqcs = "近两年逾期次数:";
		String dyzgyqje = "单月最高逾期金额:";
		String dqyqje = "当前逾期金额:";
		
		String zs =  "张数:";
		String sxze =  "授信总额:";
		String jlgysye =  "近6个月使用额:";
		
		String bs =  "笔数:";
		String ye =  "余额:";
		
		String fdye =  "房贷余额:";
		for(String mark : marks) {
			if(StringUtils.isBlank(mark)) {
				continue;
			}
			int type = 0;
			if(mark.startsWith(dy)) {
				mark = mark.substring(dy.length());
				type = 1;
			} else if(mark.startsWith(xy)){
				mark = mark.substring(xy.length());
				type = 2;
			} else if(mark.startsWith(xyk)){
				mark = mark.substring(xyk.length());
				type = 3;
			} else if(mark.startsWith(dwdb)){
				mark = mark.substring(dwdb.length());
				type = 4;
			} else if(mark.startsWith(bz)){
				mark = mark.substring(bz.length());
				type = 5;
			}
			
			String[] marks_ = mark.split(";");
			for(String mark_ : marks_) {
				if(StringUtils.isBlank(mark_)) {
					continue;
				}
				switch (type) {
				case 1:
					if(mark_.startsWith(wjqdkbs)) {
						mark_ = mark_.substring(wjqdkbs.length());
						if(StringUtils.isBlank(mark_)) {
							mark_ = "0";
						}
						zxCreditQuery.setWjqdkbsDy(mark_);
					} else if(mark_.startsWith(wjqdkye)) {
						mark_ = mark_.substring(wjqdkye.length());
						if(StringUtils.isBlank(mark_)) {
							mark_ = "0";
						}
						zxCreditQuery.setWjqdkyeDy(mark_);
					} else if(mark_.startsWith(jlgypjyh)) {
						mark_ = mark_.substring(jlgypjyh.length());
						if(StringUtils.isBlank(mark_)) {
							mark_ = "0";
						}
						zxCreditQuery.setJlgypjyhDy(mark_);
					} else if(mark_.startsWith(jlnyqcs)) {
						mark_ = mark_.substring(jlnyqcs.length());
						if(StringUtils.isBlank(mark_)) {
							mark_ = "0";
						}
						zxCreditQuery.setJlnyqcsDy(mark_);
					} else if(mark_.startsWith(dyzgyqje)) {
						mark_ = mark_.substring(dyzgyqje.length());
						if(StringUtils.isBlank(mark_)) {
							mark_ = "0";
						}
						zxCreditQuery.setDyzgyqjeDy(mark_);
					} else if(mark_.startsWith(dqyqje)) {
						mark_ = mark_.substring(dqyqje.length());
						if(StringUtils.isBlank(mark_)) {
							mark_ = "0";
						}
						zxCreditQuery.setDyyqjeDy(mark_);
					}
					break;
				case 2:
					if(mark_.startsWith(wjqdkbs)) {
						mark_ = mark_.substring(wjqdkbs.length());
						if(StringUtils.isBlank(mark_)) {
							mark_ = "0";
						}
						zxCreditQuery.setWjqdkbsXy(mark_);
					} else if(mark_.startsWith(wjqdkye)) {
						mark_ = mark_.substring(wjqdkye.length());
						if(StringUtils.isBlank(mark_)) {
							mark_ = "0";
						}
						zxCreditQuery.setWjqdkyeXy(mark_);
					} else if(mark_.startsWith(jlgypjyh)) {
						mark_ = mark_.substring(jlgypjyh.length());
						if(StringUtils.isBlank(mark_)) {
							mark_ = "0";
						}
						zxCreditQuery.setJlgypjyhXy(mark_);
					} else if(mark_.startsWith(jlnyqcs)) {
						mark_ = mark_.substring(jlnyqcs.length());
						if(StringUtils.isBlank(mark_)) {
							mark_ = "0";
						}
						zxCreditQuery.setJlnyqcsXy(mark_);
					} else if(mark_.startsWith(dyzgyqje)) {
						mark_ = mark_.substring(dyzgyqje.length());
						if(StringUtils.isBlank(mark_)) {
							mark_ = "0";
						}
						zxCreditQuery.setDyzgyqjeXy(mark_);
					} else if(mark_.startsWith(dqyqje)) {
						mark_ = mark_.substring(dqyqje.length());
						if(StringUtils.isBlank(mark_)) {
							mark_ = "0";
						}
						zxCreditQuery.setDyyqjeXy(mark_);
					}
					break;
				case 3:
					if(mark_.startsWith(zs)) {
						mark_ = mark_.substring(zs.length());
						if(StringUtils.isBlank(mark_)) {
							mark_ = "0";
						}
						zxCreditQuery.setZsXyk(mark_);
					} else if(mark_.startsWith(sxze)) {
						mark_ = mark_.substring(sxze.length());
						if(StringUtils.isBlank(mark_)) {
							mark_ = "0";
						}
						zxCreditQuery.setSxzeXyk(mark_);
					} else if(mark_.startsWith(jlgysye)) {
						mark_ = mark_.substring(jlgysye.length());
						if(StringUtils.isBlank(mark_)) {
							mark_ = "0";
						}
						zxCreditQuery.setJlgysyeXyk(mark_);
					} else if(mark_.startsWith(jlnyqcs)) {
						mark_ = mark_.substring(jlnyqcs.length());
						if(StringUtils.isBlank(mark_)) {
							mark_ = "0";
						}
						zxCreditQuery.setJlnyqcsXyk(mark_);
					} else if(mark_.startsWith(dyzgyqje)) {
						mark_ = mark_.substring(dyzgyqje.length());
						if(StringUtils.isBlank(mark_)) {
							mark_ = "0";
						}
						zxCreditQuery.setDyzgyqjeXyk(mark_);
					} else if(mark_.startsWith(dqyqje)) {
						mark_ = mark_.substring(dqyqje.length());
						if(StringUtils.isBlank(mark_)) {
							mark_ = "0";
						}
						zxCreditQuery.setDqyqjeXyk(mark_);
					}
					break;
				case 4:
					if(mark_.startsWith(bs)) {
						mark_ = mark_.substring(bs.length());
						if(StringUtils.isBlank(mark_)) {
							mark_ = "0";
						}
						zxCreditQuery.setBsDwdb(mark_);
					} else if(mark_.startsWith(ye)) {
						mark_ = mark_.substring(ye.length());
						if(StringUtils.isBlank(mark_)) {
							mark_ = "0";
						}
						zxCreditQuery.setYeDwdb(mark_);
					}
					break;
				case 5:
					if(mark_.startsWith(fdye)) {
						mark_ = mark_.substring(fdye.length());
						if(StringUtils.isBlank(mark_)) {
							mark_ = "0";
						}
						zxCreditQuery.setFdyeBz(mark_);
					}
					break;
				default:
					break;
				}
			}
		}
	}
}
